package jmine.tec.persist.schema.simple;

import static bancosys.tec.persist.hibernate.type.StaticIdEnumType.ENUM_CLASS;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import jmine.tec.persist.annotation.Alias;
import jmine.tec.persist.annotation.Constraint;
import jmine.tec.persist.annotation.UniqueConstraint;
import jmine.tec.persist.schema.common.SampleStaticEnum;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import bancosys.tec.component.Documentation;
import bancosys.tec.persist.bussobj.PersistableBusinessObject;

@Entity
@Alias("SIMP")
@Table(name = "SIMPLE")
@Documentation("TABELA")
@SequenceGenerator(name = "SEQ_SIMPLE", sequenceName = "SEQ_SIMPLE")
public class SimpleEntity extends PersistableBusinessObject {

    private Long id;

    private String mnemonico;

    private String descricao;

    private SampleStaticEnum staticEnum;

    public SimpleEntity(Long id) {
        this(id, null);
    }

    public SimpleEntity(Long id, String descricao) {
        this.id = id;
        this.descricao = descricao;
    }

    public SimpleEntity() {

    }

    /**
     * @return the id
     */
    @Id
    @GeneratedValue(generator = "SEQ_SIMPLE")
    @Column(name = "COD_SIMPLE", precision = 17, nullable = false)
    @Documentation("CODIGO")
    public Long getId() {
        return this.id;
    }

    /**
     * @return the mnemonico
     */
    @UniqueConstraint(name = "AK_SIMP_0")
    @Column(name = "MNE", length = 20, nullable = false)
    @Documentation("MNEMONICO")
    public String getMnemonico() {
        return this.mnemonico;
    }

    /**
     * @return the descricao
     */
    @Column(name = "DESCR", length = 40)
    @Documentation("DESCRICAO")
    public String getDescricao() {
        return this.descricao;
    }

    /**
     * @return the staticEnum
     */
    @Constraint(suffix = "JT_0")
    @Type(type = "bancosys.tec.persist.hibernate.type.StaticIdEnumType", parameters = @Parameter(name = ENUM_CLASS, value = "jmine.tec.persist.schema.common.SampleStaticEnum"))
    @Column(name = "STATIC_ENUM")
    @Documentation("ENUMERACAO ESTATICA.")
    public SampleStaticEnum getStaticEnum() {
        return this.staticEnum;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param mnemonico the mnemonico to set
     */
    public void setMnemonico(String mnemonico) {
        this.mnemonico = mnemonico;
    }

    /**
     * @param descricao the descricao to set
     */
    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    /**
     * @param staticEnum the staticEnum to set
     */
    public void setStaticEnum(SampleStaticEnum staticEnum) {
        this.staticEnum = staticEnum;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }
}
